<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<c:url value="/css/tableStyle.css"/>" />
<title>Setting - Insured Item</title>
<style>
</style>
<script>
	window.onload = function(){
		document.getElementById("btn_insert").onclick = insert;
	};

	function insert(){
		document.getElementById("row_insert").style.display = "";
	};
</script>
</head>
<body>

<h1>Insured Item List</h1>
<s:form namespace="/setting" method="post" action="insuredItem">
	Code<s:textfield name="model.code" value=""/>
	<s:submit cssClass="button" value="搜尋" method="select"></s:submit>
</s:form>
<input class="button1" type="button" id="btn_insert" value="新增"/>
<table style="width:1000px;">
	<thead>
		<tr>
			<th>Function</th>
			<th>Code</th>
			<th>Name</th>
			<th>Type</th>
			<th>Property</th>
			<th>SectionClass</th>
			<th>Creator</th>
			<th>CreateTime</th>
			<th>Modifier</th>
			<th>ModifiedTime</th>
		</tr>
	</thead>
	<s:form namespace="/setting" method="post" action="insuredItem">
		<tr id="row_insert" style="display: none;">
			<td>
				<s:submit cssClass="button1" value="送出" method="insert"/>
				<s:submit cssClass="button1" value="取消"/>		
			</td>
			<td><s:textfield name="model.code" value=""/></td>
			<td><s:textfield name="model.name" value=""/></td>
			<td><s:textfield name="model.type" value=""/></td>
			<td><s:textfield name="model.property" value=""/></td>
			<td><s:textfield name="model.sectionClass" value=""/></td>
			<td><s:textfield disabled="true" name="model.creator" value=""/></td>
			<td><s:textfield disabled="true" name="model.createTime" value=""/></td>
			<td><s:textfield disabled="true" name="model.modifier" value=""/></td>
			<td><s:textfield disabled="true" name="model.modifiedTime" value=""/></td>
		</tr>
	</s:form>
	<c:if test="${not empty models}">
	<tbody>
		<c:forEach items="${models}" var="item" varStatus="status">
		<s:form namespace="/setting" method="post" action="insuredItem">
		<s:hidden name="model.id" value="%{#attr.item.id}"/>
		<tr>
			<td>
				<s:submit cssClass="button" value="修改" method="update"/>
				<s:submit cssClass="button" value="刪除" method="delete"/>		
			</td>
			<td><s:textfield name="model.code" value="%{#attr.item.code}"/></td>
			<td><s:textfield name="model.name" value="%{#attr.item.name}"/></td>
			<td><s:textfield name="model.type" value="%{#attr.item.type}"/></td>
			<td><s:textfield name="model.property" value="%{#attr.item.property}"/></td>
			<td><s:textfield name="model.sectionClass" value="%{#attr.item.sectionClass}"/></td>
			<td><s:textfield readonly="true" name="model.creator" value="%{#attr.item.creator}"/></td>
			<joda:format var="createTime" value="${item.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
			<td><s:textfield readonly="true" name="model.createTime" value="%{#attr.createTime}"/></td>
			<td><s:textfield readonly="true" name="model.modifier" value="%{#attr.item.modifier}"/></td>
			<joda:format var="modifiedTime" value="${item.modifiedTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
			<td><s:textfield readonly="true" name="model.modifiedTime" value="%{#attr.modifiedTime}"/></td>
		</tr>
		</s:form>
		</c:forEach>
	</tbody>
	</c:if>
</table>

</body>
</html>